package com.wsl.wechat.service.impl;

import com.wsl.wechat.dataobject.ProductCategory;
import com.wsl.wechat.repository.ProductCategoryRepository;
import com.wsl.wechat.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @Author:wangshuliang
 * @Description:
 * @Date:Created in 8:50 2019/5/29
 * @Modified by:
 */
@Service
public class CategoryTypeServiceImpl implements CategoryService {
    @Autowired
    private ProductCategoryRepository repository;
    @Override
    public ProductCategory findOne(Integer categoryId) {
        Optional<ProductCategory> byId = repository.findById(categoryId);
        if (byId.isPresent()){
            return byId.get();
        }
        return null;
    }

    @Override
    public List<ProductCategory> findAll() {
        return repository.findAll();
    }

    @Override
    public List<ProductCategory> findByCategoryTypeIn(List<Integer> categoryTypeList) {
        return repository.findByCategoryTypeIn(categoryTypeList);
    }

    @Override
    public ProductCategory save(ProductCategory productCategory) {
        return repository.save(productCategory);
    }
}
